#!/bin/bash

tmux has-session -t mywork
if [ $? != 0 ]; then
    tmux new-session -s mywork -n editor -d -e 'VIM_SERVER_NAME=mywork' -c '/opt/sources/mynotes'
    tmux send-keys -t mywork 'vim --servername mywork README.md' C-m
    tmux new-window -n ranger -t mywork 'VIM_SERVER_NAME=mywork ranger ~/Downloads /opt/sources/mynotes /opt/sources/code_learning /opt/sources/mycode'
    tmux new-window -n notes -t mywork -c /opt/sources/mynotes
    tmux send-keys -t mywork "alias vt='vim --servername mywork --remote-tab'" C-m
    tmux send-keys -t mywork "clear" C-m
    tmux new-window -n taskbook -t mywork
    tmux send-keys -t mywork 'tb -l' C-m
    tmux select-window -t mywork:4
fi

if [ -z "$TMUX" ]; then
    tmux -u attach-session -t mywork
else
    tmux -u switch-client -t mywork
fi
